LoRa
api.loraSend(ack, timeout, msg, port)
- Overview
- Arguments
- Return
- Example
Sends buffer msg to LoRa. Acknowledged or non-acknowledged transport can be used using ack parameter. Maximum execution time is limited by timeout in milliseconds.
- ack (integer) - Selects acknowledged (1) or non-acknowledged (0) transmission mode
- timeout (integer) - The maximum execution time in milliseconds, used in acknowledged mode
- msg (string) - String to be sent to LoRa
- port (integer) - Port number (OPTIONAL)
- status (integer) - Positive or zero for success, negative for failure
- port (integer) - Nil or port on which the answer was received
- answer (string) - Nil or non-zero length string containing gateway answer
--sends 0xCCBBAA35 to LoRa with 20s timeout and acknowledged mode
msg = pack.pack('<b4', 0xCC, 0xBB, 0xAA, 0x35)
status, port, answer = api.loraSend(1,20000, msg)
if status >= 1 then --checks if device received more than one 1 byte
api.dumpArray(answer) --if true, print the data
end
api.loraJoin(int, dr)
- Overview
- Arguments
- Example
Sends join request.
Rejoin is made automaticaly once per 7 days by default, but it can be changed using following "api.loraSetup" function.
- int (integer) - if the number is 0, then it checks for security context (which is stored in memory after successful join request), if there's none, the it sends join request. If the number is 1, join request is forced.
- dr (integer)(optional) - sets join Data Rate (in range from 0 to 5)
-- check if joined, if not join ...
api.loraJoin()
-- join!
api.loraJoin(1)
api.loraSetup(s1, s2)
- Overview
- Arguments
- Example
Sets parameters defined by strings s1 and s2.
This function resets previous activation settings. Meaning, if you call repeatedly api.loraSetup("ACTIVATION", "OTAA") it'll send join request each time this function is called.
- s1 (string) - Defining parameter to be set. Here's a list of those parameters:
“ACTIVATION”
- Type of activation“ADR”
- Adaptive Data Rate“DR”
- Data Rate“DC”
- Duty Cycle“OTAA-REJOIN-CONFIRMED-FAILED-COUNTER"
- Sets number of confirmed messages after join reuest (cannot be lower than 5, which is also default number)"OTAA-MINIMAL-CONFIRMED-PERIOD"
- Sets period of time (in milliseconds) to send join reuest (by default 7 days)
- s2 (string, integer)
options in case of:
- ACTIVATION -
"OTAA"
,"ABP"
- ADR - select between 1 (on) and 0 (off)
- DR - chose number in range from 0 to 5
- DC -
"ON"
,"OFF"
,"DCTIME"
,"GET"
- ACTIVATION -
--set activation type as ABP
api.loraSetup("ACTIVATION", "ABP")
--set data rate to 0
api.loraSetup("DR", 0)
api.loraListenClassC(timeout)
- Overview
- Arguments
- Return
- Example
Listens for message until received or timeout in class C.
- timeout (integer) - Timeout of listening in milliseconds, default is 10000 ms (OPTIONAL)
- status (integer) - Positive or zero for success, negative for failure
- port (integer) - Communication port
- buffer (string) - Message received from LoRa
--Listen on LoRa for a message with default timout of 10 seconds
status, port, buffer = api.loraListenClassC()
api.loraSetCredential(var1, var2)
- Overview
- Arguments
- Example
Sets only one LoRa credential.
By Calling this function, the converter also sends Join request.
- var1 (string) - selects one credential to be changed - devADDR, devEUI, nwkSKey, appSKey, appEUI
- var2 (string) - desired string for selected credential
--Set one LoRa credential (in this case devEUI)
api.loraSetCredential("devEUI", "3333333333333333")
api.loraSetCredentials(devADDR, devEUI, nwsKey, appsKey, appEUI)
- Overview
- Arguments
- Example
Sets LoRa credentials.
By Calling this function, the converter also sends Join request.
- devADDR (string) - Device ADDR
- devEUI (string) - Device EUI
- nwsKey (string) - NWS key
- appsKey (string) - APPS key
- appEUI (string) - Application EUI (OPTIONAL)
--Set LoRa credentials
api.loraSetCredentials("22011221","3333333333333333","44444444444444444444444444444444","55555555555555555555555555555555","70B344440013333")